home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Tools & Apps / Graphics & Imaging / SLUDGE 2.0 / Source Code / Parasite_Manager.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-14  |  7.1 KB  |  141 lines  |  [TEXT/MPS ]

  1. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  2.   •                                                                           •
  3.   •   File Name:    Parasite_Manager.c                                          •
  4.   •   ----------                                                              •
  5.   •                                                                           •
  6.   •   Copyright © 1990 Apple Computer, Inc.  All Rights Reserved              •
  7.   •                                                                           •
  8.   •       Description                                                         •
  9.   •       -----------                                                         •
  10.   •       This file contains the routines of the parasite manager.              •
  11.   •          The parasite manager will install and remove the SLUDGE parasite.   •
  12.   •          The SLUDGE parasite is what slows down the machine.                  •
  13.   •                                                                           •
  14.   •       History                                                             •
  15.   •       -------                                                             •
  16.   •                                                                           •
  17.   •       Author          Date            Description                         •
  18.   •       ------------------------------------------------------------------  •
  19.   •       Kevin McEntee   2/20/90         Original Implementation             •
  20.   •                                                                           •
  21.   •                                                                           •
  22.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  23. #include    <OSUtils.h>
  24. #include    <Resources.h>
  25. #include    <Memory.h>
  26.  
  27. #include    "Parasite_Manager.h"
  28. #include    "State_Storage_Manager.h"
  29.  
  30.  
  31. void TRY(Ptr Parasite_Location, long Sludge_Factor);
  32.  
  33. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  34.   •                                                                           •
  35.   •   Identifier:      Install                                                  •
  36.   •   -----------                                                             •
  37.   •                                                                           •
  38.   •       Description                                                         •
  39.   •       -----------                                                         •
  40.   •       This function installs the SLUDGE parasite and makes it active.      •
  41.   •                                                                           •
  42.   •       History                                                             •
  43.   •       -------                                                             •
  44.   •                                                                           •
  45.   •       Author          Date            Description                         •
  46.   •       ------------------------------------------------------------------  •
  47.   •       Kevin McEntee   2/20/90         Original Implementation             •
  48.   •                                                                           •
  49.   •                                                                           •
  50.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  51. void Install(Handle cdevStorage, long Sludge_Factor)
  52. {
  53.     Handle  SLUDGE_parasite;
  54.     short    rvalue;
  55.     Handle  a_trap_vector_address = 0x28;
  56.     Handle  jt_vector_address = 0x24;
  57.  
  58.  
  59.                                          /*••••••••••••••••••••••••••••••••••••••••••
  60.                                            •                                        •
  61.                                            •    Save the values of the Jump_Trace     •
  62.                                            •    a-trap exception vectors.            •
  63.                                            •                                        •
  64.                                            ••••••••••••••••••••••••••••••••••••••••••*/
  65.     Set_Original_A_TRAP_Exception_Vector_Value(cdevStorage, *a_trap_vector_address);
  66.     Set_Original_JUMP_TRACE_Exception_Vector_Value(cdevStorage, *jt_vector_address);
  67.     
  68.                                          /*••••••••••••••••••••••••••••••••••••••••••
  69.                                            •                                        •
  70.                                            •    Load the parasite resource.            •
  71.                                            •                                        •
  72.                                            ••••••••••••••••••••••••••••••••••••••••••*/
  73.     
  74.     
  75.     SLUDGE_parasite = GetResource('NUGG',0);
  76.     
  77.     rvalue = ResError();
  78.     
  79.     if (rvalue != 0)
  80.         DebugStr("\pGetResource Failed");
  81.     
  82.     DetachResource(SLUDGE_parasite);
  83.     rvalue = ResError();
  84.     
  85.     if (rvalue != 0)
  86.         DebugStr("\pDetachResource Failed");
  87.         
  88.     
  89.     HLock(SLUDGE_parasite);
  90.     
  91.     Set_Location_Of_Parasite_Resource(cdevStorage, SLUDGE_parasite);
  92.     
  93.                                          /*••••••••••••••••••••••••••••••••••••••••••
  94.                                            •                                        •
  95.                                            •    Activate the parasite.                •
  96.                                            •                                        •
  97.                                            ••••••••••••••••••••••••••••••••••••••••••*/
  98.     TRY(*SLUDGE_parasite, Sludge_Factor);
  99.     
  100. }
  101.  
  102.  
  103. #include    <OSUtils.h>
  104. void CLEAR_JUMP_TRACE_BIT();
  105.  
  106.  
  107. /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  108.   •                                                                           •
  109.   •   Identifier:     remove                                                      •
  110.   •   -----------                                                             •
  111.   •                                                                           •
  112.   •       Description                                                         •
  113.   •       -----------                                                         •
  114.   •       This function makes the SLUDGE parasite inactive and removes it.      •
  115.   •                                                                           •
  116.   •       History                                                             •
  117.   •       -------                                                             •
  118.   •                                                                           •
  119.   •       Author          Date            Description                         •
  120.   •       ------------------------------------------------------------------  •
  121.   •       Kevin McEntee   2/20/90         Original Implementation             •
  122.   •                                                                           •
  123.   •                                                                           •
  124.   •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  125. void remove(Handle cdevStorage)
  126. {
  127.     Handle  SLUDGE_parasite;
  128.     Handle  a_trap_vector_address = 0x28;
  129.     Handle  jt_vector_address = 0x24;
  130.     
  131.     CLEAR_JUMP_TRACE_BIT();
  132.     
  133.     
  134.     *a_trap_vector_address = Get_Original_A_TRAP_Exception_Vector_Value(cdevStorage);
  135.     *jt_vector_address = Get_Original_JUMP_TRACE_Exception_Vector_Value(cdevStorage);
  136.     
  137.     SLUDGE_parasite = Get_Location_Of_Parasite_Resource(cdevStorage);
  138.     HUnlock(SLUDGE_parasite);
  139.     DisposHandle(SLUDGE_parasite);
  140.     
  141. }